UserUnitWindow = function(title){
	//定义一个load方法给让表单加载数据信息
	var loadInfo = function(rec){
		form.getForm().loadRecord(rec);
		
	}
	//获取表单信息并定义事件
	var submit = function(){
		if(form.getForm().isValid()){
			var data = form.getForm().getValues();
		    var win = form.ownerCt;
		    win.fireEvent('submit',win,form,data);
		}else{
			Ext.MessageBox.alert('系统提示','请填写合适的数据!');
		}
		
	}
	//小区数据集
	var areastore = new Ext.data.JsonStore(
		{
			url:__ctxPath+'/back/area/findallareainfo.html',
			autoLoad:true,
			fields:['aid','name']
		}
	);
	//建立form表单
	var form = new Ext.form.FormPanel(
		{
			frame:true,
			enableKeyEvents: true,
			defaults:{
				anchor:'90%',
				maxLength:50,
				maxLengthText:'最多不能超过50个字',
				listeners : {  
	                specialkey : function(field, e) {  
	                    if (e.getKey() == Ext.EventObject.ENTER) {  
	                        submit();
	                    }  
	                }  
	            }  
			},
			autoHeight: true,
			items:[
				{
					xtype:'combo',
					hiddenName:'areaid',
					name:'areaid',
					editable:false,
					store:areastore,
					valueField:'aid',
					displayField:'name',
					mode:'remote',
					triggerAction:'all',
					allowBlank:false,
					tabIndex:1,
					blankText:'小区名称为必填项',
					fieldLabel:'小区名称'
				},{
					xtype:'textfield',
					name:'address',
					allowBlank:false,
					blankText:'用户住址为必填项',
					tabIndex:2,
					fieldLabel:'住址'
				},{
					xtype:'textfield',
					name:'username',
					tabIndex:3,
					allowBlank:false,
					blankText:'用户姓名为必填项',
					fieldLabel:'用户姓名'
				},{
					xtype:'numberfield',
					name:'areaforbuild',
					allowBlank:false,
					decimalPrecision :2,
					decimalSeparator :'.',
					minValue	:0, 
					minText 	:'最小值为0',
					tabIndex:4,
					fieldLabel:'建筑面积'
				},{
					xtype:'textfield',
					name:'areaforfees',
					allowBlank:false,
					decimalPrecision :2,
					decimalSeparator :'.',
					minValue	:0, 
					minText 	:'最小值为0',
					tabIndex:5,
					fieldLabel:'采暖面积'
				},{
					xtype:'textfield',
					name:'telephone',
					tabIndex:6,
					allowBlank:false,
					blankText:'电话号码为必填项',
					fieldLabel:'电话号码'
				},{
					xtype:'datefield',
					name:'regdate',
					format:'Y-m-d',
					value:new Date(),
					invalidText : '格式必须为yyyy-mm-dd的格式,例如2012-01-01',
					fieldLabel:'添加日期'
				},{
					xtype:'textfield',
					name:'notes',
					tabIndex:8,
					fieldLabel:'备注'
				},{
					xtype:'hidden',
					name:'uid'
				}]
		}
	);
	
	//这里是Window的配置项
	var config = {
		load:loadInfo,
		buttons:[
			{
				text:'确定',
				iconCls:'confirm',
				handler:submit,
				scope:this
			},
			{
				text:'取消',
				iconCls:'cancel',
				handler:function(){this.close()},
				scope:this
			}],
		items:[form],
		layout:'fit',
		constrain : true, 
		constrainHeader : true, 
		modal:true,
		title:title,
		width:400,
		autoHeight:true 
	};
	UserUnitWindow.superclass.constructor.call(this,config);
}
Ext.extend(UserUnitWindow,Ext.Window);